from iot.models import Point
from dvadmin.utils.serializers import CustomModelSerializer
from dvadmin.utils.viewset import CustomModelViewSet


class PointModelSerializer(CustomModelSerializer):
    def save(self, **kwargs):
        self.validated_data['dept_belong_id'] = self.validated_data['cabinet'].dept.id
        return super().save(**kwargs)

    class Meta:
        model = Point
        fields = '__all__'


class PointModelViewSet(CustomModelViewSet):
    queryset = Point.objects.all()
    serializer_class = PointModelSerializer
